﻿<%@ Page Title="好友资料" Language="C#" MasterPageFile="~/member/mMenber.master" AutoEventWireup="true" CodeBehind="FriendInfo.aspx.cs" Inherits="map.member.FriendInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head2" runat="server">
    <link href="../outstyle.css" rel="stylesheet" type="text/css" />
    <script src="../js/dropdowncontent.js" type="text/javascript"></script>
    <style type="text/css">
         .mainContentDiv
         {
             width:1000px;
         }
         .td_left
         {
             text-align:right;
             width:25%;
             vertical-align:top;
         }
         .td_right
         {
             text-align:left;
         }
         h2
         {
             font-size:larger;
         }
         .isFriend
         {
             font-size:15px;
         }
         .DetailInfoDiv
         {
             border:solid 1px #ECECEC;
             width:100%;
         }
         .DetailInfoDiv ul
         {
             margin-left:20px;
         }
         .DetailInfoDiv ul li
         {
             list-style-type:none;
             border-bottom:dashed 1px #ECECEC;
             padding-top:5px;
         }
         .SchollStyle
         {
             width:150px;
             color:Blue;
         }
         .YearStyle
         {
             width:100px;
         }
         .td1
         {
             text-align:right;
             width:20%;
         }
         .td2
         {
             width:150px;
         }
         .td3
         {
             width:100px;
         }
         .td4
         {
             text-align:left;
         }
         #map_canvas
         {
             width:400px;
             height:300px;
         }
         .DetailInfoDiv span
         {
             color:Blue;
         }
         .add-button
         {
             line-height:23px;
             height:23px;
             background:url(../img/add-button.png) no-repeat;
             font-size :12px;
             float:left;
             width:120px;
             text-indent:45px;
             text-decoration:none;
             margin-top:5px;
         }
         .input-button,.input-submit{background-color:#005eac;border-color:#b8d4e8 #124680 #124680 #b8d4e8;border-style:solid;border-width:1px;color:#fff;cursor:pointer;font-size:12px;padding:2px 15px;text-align:center}
         .searchItemsDiv
       {
           width:100%;
       }
       .searchFilterDiv
       {
           border:solid 1px #ECECEC;
           padding:5px 0px 5px 0px;
           padding-left:350px;
           width:650px;
       }
       .anchorParentDiv a
       {
           background:transparent url(../img/toggle_bg.gif) no-repeat scroll 0px -80px;
           overflow:hidden ;
           display:block;
           height:20px;
           width:100%;
           margin:0 auto;
           text-indent:-999em;
       }
       .anchorParentDiv a:hover
       {
           background-position:0px -120px;
       }
       .anchorParentDiv a.collapsed
       {
           background-position:0px 0px;
       }
       .anchorParentDiv a.collapsed:hover
       {
           background-position:0px -40px;
       }
       .anchorParentDiv
       {}
    </style>
    <link href="../css/popup.css" rel="stylesheet" type="text/css" />

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
<asp:Literal ID="Literal_map" runat="server"></asp:Literal>
    <div id="maskDiv" style =" position :absolute ;top:0px; left :0px;   visibility :hidden ; background-color :#666;  z-index :1;"></div>

    <%--搜索朋友--%>
    <div class ="searchItemsDiv">  
        <div class ="searchFilterDiv" id="searchFilterDiv" style=" display:none">
            <div style =" float :left ;">
                <img  src ="../img/guide4.png"/>
            </div>
            <div style =" padding-left:40px;">
                <h2 style =" color:#3300CC">找到您的朋友们</h2>
                <input type ="text" id="searchKeysInputText" value ="可输入姓名 学校 单位"  onblur ="if(this.value=='') this.value='可输入姓名 学校 单位';"  onfocus ="if(this.value=='可输入姓名 学校 单位')this.value='';"/>
                <input  type ="button" class="input-button" value="搜索" onclick="searchKeysButtonClick();"/>
                <a href ="advanceSearch.aspx" style=" padding-top:2px;color:#3300CC">高级搜索</a>
            </div>
        </div> 
        <div class="anchorParentDiv" style =" text-align:center; padding-left:15%;">
            <a id="searchFilterAnchor" title ="展开/折叠 搜索好友" onclick ="collapseByAnchor(this);">展开/折叠</a>
        </div>
    </div>
    <br />
            
    <div class="mainContentDiv">
        <table width="100%">
            <tr>
                <td style=" text-align:left">
                    <h2>
                        您正在查看
                        <asp:Label ID="IsFriendLabel" CssClass ="isFriend" runat="server" Text="Label"></asp:Label>
                        <asp:HyperLink ID="FriendNickHyperLink" CssClass ="isFriend" NavigateUrl="#" runat="server">Nick</asp:HyperLink>
                        的资料：
                    </h2>
                </td>
                <td style=" width:500px;  ">
                    <div runat="server" id="AddToFriendDiv0">
                        <a href="#1" onclick ="showaddNewFriends();"><span class="add-button" >加为好友</span></a>
                    </div>
                </td>                              
            </tr>
        </table> 
        
        <div class="DetailInfoDiv">
            <ul  style =" width:100%;">
                <%--个人信息--%>
                <li>
                   <h3>个人信息</h3>
                   <table width="100%">
                        <tr>
                            <td class="td_left">
                                姓名：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="NameLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                昵称：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="NickLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                性别：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="SexLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                电子邮箱：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="EmailLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                    </table>
                </li>
                <%--联系方法--%>
                <li>
                   <h3>联系方法</h3>
                   <table width="100%">
                        <tr>
                            <td class="td_left">
                                手机：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="MobilePhoneLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                QQ号码：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="QQNumberLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                MSN号码：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="MSNNumberLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                曾经工作的单位：
                            </td>
                            <td class="td_right">
                                <asp:Label ID="LastEmployeeLabel" runat="server" Text=" "></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                初中所在的学校：
                            </td>
                            <td class="td_right">
                                <table>
                                    <tr>
                                        <td class ="SchollStyle">
                                            <asp:Label ID="JSchollLabel"   CssClass="SchollStyle" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td class="td2">
                                            毕业于：
                                        </td>
                                        <td class="YearStyle">
                                            <asp:Label ID="JSchollYearLabel" CssClass ="YearStyle" runat="server" Text=" "></asp:Label>
                                        </td>
                                    </tr>
                                </table>   
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                高中所在的学校：
                            </td>
                            <td class="td_right">
                                <table>
                                    <tr>
                                        <td class ="SchollStyle">
                                            <asp:Label ID="SSchollLabel"   CssClass="SchollStyle" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td class="td2">
                                            毕业于：
                                        </td>
                                        <td class="YearStyle">
                                            <asp:Label ID="SSchollYearLabel" CssClass ="YearStyle" runat="server" Text=" "></asp:Label>
                                        </td>
                                    </tr>
                                </table>     
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                大学所在的学校：
                            </td>
                            <td class="td_right">
                                <table>
                                    <tr>
                                        <td class ="SchollStyle">
                                            <asp:Label ID="CollageLabel"  CssClass="SchollStyle" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td class="td2">
                                            毕业于：
                                        </td>
                                        <td class="YearStyle">
                                            <asp:Label ID="CollageYearLabel" CssClass ="YearStyle" runat="server" Text=" "></asp:Label>
                                        </td>
                                    </tr>
                                </table>                        
                            </td>
                        </tr>                        
                    </table>
                </li>
                <%--现居住地信息--%>
                <li>
                   <h3>现居住地信息</h3>
                   <table width="100%">
                        <tr>                            
                            <td class ="td_left">
                                省：
                            </td>
                            <td  class="td_right">
                               <table style=" width:100%;">
                                    <tr>
                                        <td class ="td2">
                                            <asp:Label ID="ProvinceLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                        <td class ="td3"></td>
                                        <td class ="td4"> </td>
                                    </tr>
                               </table> 
                            </td>
                        </tr>
                         <tr>                            
                            <td class ="td_left">
                                县：
                            </td>
                            <td  class="td_right">
                               <table style=" width:100%;">
                                    <tr>
                                        <td class ="td2">
                                            <asp:Label ID="CityLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                        <td class ="td3">
                                            地区：
                                        </td>
                                        <td class ="td4">
                                            <asp:Label ID="DistrictLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                    </tr>
                               </table> 
                            </td>
                        </tr>
                         <tr>                            
                            <td class ="td_left">
                                区域：
                            </td>
                            <td class="td_right">
                               <table style=" width:100%;">
                                    <tr>
                                        <td class ="td2">
                                            <asp:Label ID="AreaLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                        <td class ="td3">
                                            小区：
                                        </td>
                                        <td class ="td4">
                                            <asp:Label ID="UserBizAreaLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                    </tr>
                               </table> 
                            </td>
                        </tr>
                        <tr>                            
                            <td class ="td_left">
                                经度：
                            </td>
                            <td class="td_right">
                               <table style=" width:100%;">
                                    <tr>
                                        <td class ="td2">
                                            <asp:Label ID="LngLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                        <td class ="td3">
                                            纬度：
                                        </td>
                                        <td class ="td4">
                                            <asp:Label ID="LatLabel" runat="server" Text=" "></asp:Label> 
                                        </td>
                                    </tr>
                               </table> 
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left">
                                地图上的位置：
                            </td>
                            <td class="td_right">
                                <span style ="color:Red ;  font-size:small ; display:none;">他还未标注自己的位置！！</span>
                                <div id="map_canvas" style="width: 530px; height: 300px; border-color: Gray; border-style: solid;
                                        border-width: 1px;">
                                </div>
                            </td>
                        </tr>
                    </table>
                </li>
                <li style =" text-align:center; height:40px; padding-left:300px; border-bottom:none;">
                     <div runat="server" id="AddToFriendDiv1">
                        <a href="#2" onclick ="showaddNewFriends();"><span class="add-button" >加为好友</span></a>
                    </div>
                </li>
            </ul>               
        </div>
    </div>
    
    
    <%--添加好友--%>
        <div class="sample_popup" id="popup" style=" position:absolute ; height:200px; width :400px; z-index :2;  display :none; ">
            <div class="menu_form_header" id="popup_drag">
                <table>
                    <tr>
                        <td>
                            添加好友：
                        </td>
                        <td>
                            <img alt="" class="menu_form_exit" onclick="document.getElementById('popup_exit').click()" src="../img/closes.png" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="menu_form_body">    
                <div style =" width :100%;">
                    <table width="100%">
                        <tr>
                            <td style =" width:200px;">
                                <table width="200px">
                                    <tr>
                                        <td colspan="2">
                                            您将添加 <a id="NewFriendIdAnchor" style=" text-decoration:underline" href ="#"></a>为好友
                                            <input type ="hidden"  value="" id="NewFriendIdHiddenInput" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  >
                                            <span style =" text-align :left ">选择分组：</span>
                                        </td>
                                        <td>
                                            <select id="NewFriendGroupSelect">
                                                <option value ="" selected ="true">请选择分组</option>
                                            </select>
                                        </td>
                                    </tr>                        
                                    <tr>
                                        <td >
                                            <span style =" text-align :left ">备注名称(可选)：</span>
                                        </td>
                                        <td style =" text-align:left">
                                            <input id="FriendNickText" type="text" style="width: 100px" />
                                        </td>
                                    </tr>
                                </table>                                         
                            </td>
                            <td style =" width:100px; text-align:center;">
                                <img  style =" padding-top:10px; width:80px; height :80px;" id="NewFriendImg"/>
                            </td>
                        </tr>
                    </table>                             
                </div>
                <div style="text-align: center;  width: 100%">
                    <input id="AddButton" type="button" value="增加" onclick=" if( addFriend()==true) document.getElementById('popup_exit').click();" />
                    <input id="popup_exit" type="button" value="取消"  />
                </div>
                <%-- <input id="GroupIdHidden" type="hidden"  />--%>
            </div>
        </div>

    
    <script src="../js/PopupDiv.js" type="text/javascript"></script>
    <script type="text/javascript">
        var mymap;
        function showAddress(address) {
            if (geocoder) {
                geocoder.getLatLng(
                  address,
                  function(point) {
                      if (!point) {
                          alert("不能解析: " + address);
                      } else {
                          map.setCenter(point, 13);
                          var marker = new GMarker(point);
                          map.addOverlay(marker);
                      }
                  }
            );
            }
        }

        function initMap() {
            map = new GMap2(document.getElementById("map_canvas"));
            //map.setMapType(G_NORMAL_MAP);
            map.addControl(new GMapTypeControl());
            map.addControl(new GLargeMapControl());
            map.enableContinuousZoom();
            //map.addControl(new GOverviewMapControl());
            map.disableDragging();
            geocoder = new GClientGeocoder();
            //map.enableGoogleBar();
            G_NORMAL_MAP.getMinimumResolution = function() {
                return 10
            };
            G_NORMAL_MAP.getMaximumResolution = function() {
                return 19
            };
        }
        window.onload = function() {
            initMap();
            var notMark = true;
            var address = "";
            var lat = 0;
            var lng = 0;
            var recid = PageUtil.getQueryString("id");
            var result = AjaxFunction.getUserLocation(recid);
            if (result.value != null && result.value != "") {
                var user = eval("("+result.value+")");
                address = user.state;
                lat = user.lat;
                lng = user.lng;
            }
            try {
                if (lat != 0 && lng != 0) {
                    var point = new GLatLng(lat, lng);
                    map.setCenter(point, 13);
                    var marker = new GMarker(point);
                    map.addOverlay(marker);
                    notMark = false;
                }
                else {
                    if (address != "") {
                        showAddress(address);
                        notMark = false;
                    }
                }
            }
            catch (e) {
            }
            if (notMark)
                showAddress("北京"); 
            var mapdiv = document.getElementById("map_canvas");
            var parentTd = mapdiv.parentNode;
            parentTd.getElementsByTagName("span")[0].style.display =((notMark ==true ) ?"block":"none");
        }

        var PageUtil = window.PageUtil || {};
        PageUtil = {
            getQueryString: function(queryName) {
                var queryValue = "";
                var queryFound = false;
                if (window.location.search != "") {
                    var search = window.location.search;
                    var i = 0;
                    while (i <= search.length) {
                        start = i;
                        end = start + queryName.length;
                        if (search.substring(start, end) == queryName) {
                            queryFound = true;
                            break;
                        }
                        i++;
                    }
                    if (queryFound) {
                        start = end + 1;
                        end = search.indexOf("&", start);
                        if (end < start)
                            end = search.length;
                        var getvalue = search.substring(start, end);
                        return unescape(getvalue);
                    }
                }
                return queryValue;
            }
        }

        //添加好友
        function showaddNewFriends() {
            var currentUserId = AjaxFunction.GetCurrentUserId().value;
            if (currentUserId != null && currentUserId != "") {
                var mtop = parseInt(250) + "px";
                var mleft = parseInt(400) + "px";
                var recid = PageUtil.getQueryString("id");
                var friendInfoResult = AjaxFunction.getUserLocation(recid);
                if (friendInfoResult.value != null && friendInfoResult.value != "") {
                    var friendInfo = eval("("+friendInfoResult.value+")");
                    initAddFriendDiv(friendInfo.userid, friendInfo.nick, friendInfo.imgPath, currentUserId);
                    popup_show('popup', 'popup_drag', 'popup_exit', mtop, mleft, true, 'maskDiv', 50);
                }
            }
            else {
                clearAddFriendDiv();
                alert("对不起，您还未登录，请先登录！");
                window.location.href = "../member/login.aspx";
            }
        }
        function clearAddFriendDiv() {
            document.getElementById("NewFriendImg").src = "";
            document.getElementById("NewFriendIdAnchor").innerHTML = "";
            document.getElementById("NewFriendIdHiddenInput").value = "";
            document.getElementById("FriendNickText").value = "";
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            newOptionEle.innerHTML = "请选择分组";
            newOptionEle.value = "";
            newOptionEle.selected = "true";
            friendGroupSelect.appendChild(newOptionEle);
        }
        function initAddFriendDiv(friendsId, friendsName, friendImgPath, currentUserid) {
            document.getElementById("NewFriendImg").src = ((friendImgPath == "") ? "../img/userdefaultimg.gif" : friendImgPath);
            document.getElementById("NewFriendIdAnchor").innerHTML = friendsName;
            document.getElementById("NewFriendIdHiddenInput").value = friendsId;
            document.getElementById("FriendNickText").value = friendsName;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            var allGroupResult = AjaxFunction.GetCurrentGroupList();
            if (allGroupResult.value != null && allGroupResult.value != "") {
                var allGroupList = eval(allGroupResult.value);
                for (var i = 0; i < allGroupList.length; i++) {
                    newOptionEle = document.createElement("option");
                    if (i == 0)
                        newOptionEle.selected = "true";
                    newOptionEle.value = allGroupList[i].id;
                    newOptionEle.innerHTML = allGroupList[i].name;
                    friendGroupSelect.appendChild(newOptionEle);
                }
            }
        }
        function addFriend() {
            var friendsName = document.getElementById("NewFriendIdAnchor").innerHTML;
            var friendsId = document.getElementById("NewFriendIdHiddenInput").value;
            var friendsNick = document.getElementById("FriendNickText").value;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");

            if (friendsNick.replace(/\s/g, "") == "") {
                alert("对不起，好友昵称不能为空！");
                return false;
            }
            var friendsGroupId = friendGroupSelect[friendGroupSelect.selectedIndex].value;
            var result = AjaxFunction.AddNewFriend(friendsGroupId, friendsId, friendsNick);
            if (result.value != null && result.value == "") {
                initSystemRecommendFriends();
                updateBindPager();
                alert("添加成功");
                return true;
            }
            else {
                if (result.value == null)
                    alert("添加失败");
                else
                    alert(result.value);
                return false;
            }
        }
        //搜索
        function searchKeysButtonClick() {
            var searchKeys = document.getElementById("searchKeysInputText").value;
            if (searchKeys == "可输入姓名 学校 单位") {
                searchKeys = "";
            }
            window.location.href = "searchFriends.aspx?type=0&searchkeys=" + encodeURI(searchKeys);
        }

        function collapseByAnchor(thisObj) {
            var searchfilterdiv = document.getElementById("searchFilterDiv");
            if (searchfilterdiv.style.display != "none") {
                thisObj.className = "collapsed";
                searchfilterdiv.style.display = "none";
                //setCookie("searchFilterDisplay", "none");
            }
            else {
                thisObj.className = "";
                searchfilterdiv.style.display = "block";
                //setCookie("searchFilterDisplay", "block");
            }
        }
    </script>
</asp:Content>
